<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<input type="text" onkeydown="fn1()" onkeypress="fn2()" onkeyup="fn3()">
<body>
<script>
    //键盘的事件
    function fn1(){
        console.log("某个键盘事件被按下")
    }
    function fn2(){
        console.log("某个键盘被按下并且松开")
    }
    function fn3(){
        //得到键盘被按下的值
        var key = event.keyCode;
        console.log(key)
    }


</script>
</body>
</html>